package leetcode.N1_N100;

/**
 * @author xiwai [hww282306@alibaba-inc.com]
 * @version 1.0
 * @date 2020/10/9 8:10 下午
 */
public class N26 {

    public int removeDuplicates(int[] nums) {
        int length = nums.length;
        if (length == 0) {
            return 0;
        }
        int index = 1;
        int val = nums[0];
        for (int i = 1; i < length; i++) {
            int temp = nums[i];
            if (temp == val) {
                continue;
            }
            nums[index++] = val = temp;
        }
        return index;
    }

}
